fix OOB array index in circle segment calculation #5317
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Version/Branch of Dear ImGui:
master
Back-end/Renderer/Compiler/OS:
Windows, Dx11
My Issue/Question:
A few months ago in production this crash happened to our users as an extremely rare edge case.
The crash ceased to occur when adding the bounds check before the array is indexed.
Screenshots/Video:
I did not archive anything from that time.
Standalone, minimal, complete and verifiable example:
Call
_CalcCircleAutoSegmentCount
with something negative and watch what happens.P.S. I did not go and try to see if this function receiving a negative value was a side effect of another part of the codebase. I did what was necessary to fix the crash and did not observe any consequences of adding the bounds check.